﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace PowerGuiVsx.Module.Objects
{
    public class Project 
    {
        internal Project(EnvDTE.Project project)
        {
            File = new FileInfo(project.FullName);

            List<ProjectProperty> properties = new List<ProjectProperty>();

            foreach(EnvDTE.Property property in project.Properties)
            {
                properties.Add(new ProjectProperty(property));
            }
            Properties = properties;

            try
            {
                var outputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();

                var outputDirectory = Path.Combine(File.DirectoryName, outputPath);

                OutputFile = new FileInfo(Path.Combine(outputDirectory, project.Properties.Item("OutputFileName").Value.ToString()));
            }
            catch
            {
            }
        }

        public FileInfo File { get; private set; }
        public FileInfo OutputFile { get; private set; } 
        public IEnumerable<ProjectProperty> Properties {get; private set; }
    }

    public class ProjectProperty
    {
        internal ProjectProperty(EnvDTE.Property property)
        {
            try
            {
                Name = property.Name;
                Value = property.Value;
            }
            catch
            {
                
            }
            
        }

        public string Name {get; private set; }
        public object Value {get; private set; }
    }
}
